﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Medianamik.Core.Lock
{
    /// <summary>
    /// Classe représentant les infos d'un Lock
    /// </summary>
    /// 
    [Serializable()]
    public class LockInfo
    {
        public LockInfo(string user, DateTime activationDate, TimeSpan ultimatum, Guid objectId)
        {
            if (!String.IsNullOrEmpty(user))
                User = user;
            else
                User = "n/a";

            ActivationDate = activationDate;
            Ultimatum = ultimatum;
            ObjectId = objectId;
        }

        public string User { get; private set; }
        private DateTime ActivationDate {  get; set; }
        public TimeSpan Ultimatum { get; private set; }
        public Guid ObjectId { get; private set; }
       
        public TimeSpan RemainingTime
        {
            get
            {
                return ExpirationDate  - DateTime.Now;
            }
        }

        public DateTime ExpirationDate
        {
            get
            {
                return ActivationDate.Add(Ultimatum);
            }
        }
    }
}